package com.ruoyi.web.controller;

import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.VideoInfo;
import com.ruoyi.system.service.IVideoInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 视频后台管理Controller
 * 
 * @author ruoyi
 * @date 2025-01-16
 */
@RestController
@RequestMapping("/system/VideoInfo")
public class VideoInfoController extends BaseController
{
    @Autowired
    private IVideoInfoService videoInfoService;

    /**
     * 查询视频后台管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:VideoInfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(VideoInfo videoInfo)
    {
        startPage();
        List<VideoInfo> list = videoInfoService.selectVideoInfoList(videoInfo);
        return getDataTable(list);
    }



    @GetMapping("/year/qs")
    @Anonymous
    public AjaxResult qs()
    {

        return success(videoInfoService.selectYearqsList());
    }



    @GetMapping("/year/aaa")
    @Anonymous
    public AjaxResult aaaa()
    {

        return success("sdfdsf");
    }


    /**
     * 导出视频后台管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:VideoInfo:export')")
    @Log(title = "视频后台管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VideoInfo videoInfo)
    {
        List<VideoInfo> list = videoInfoService.selectVideoInfoList(videoInfo);
        ExcelUtil<VideoInfo> util = new ExcelUtil<VideoInfo>(VideoInfo.class);
        util.exportExcel(response, list, "视频后台管理数据");
    }

    /**
     * 获取视频后台管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:VideoInfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(videoInfoService.selectVideoInfoById(id));
    }

    /**
     * 新增视频后台管理
     */
    @PreAuthorize("@ss.hasPermi('system:VideoInfo:add')")
    @Log(title = "视频后台管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VideoInfo videoInfo)
    {
        return toAjax(videoInfoService.insertVideoInfo(videoInfo));
    }

    /**
     * 修改视频后台管理
     */
    @PreAuthorize("@ss.hasPermi('system:VideoInfo:edit')")
    @Log(title = "视频后台管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VideoInfo videoInfo)
    {
        return toAjax(videoInfoService.updateVideoInfo(videoInfo));
    }

    /**
     * 删除视频后台管理
     */
    @PreAuthorize("@ss.hasPermi('system:VideoInfo:remove')")
    @Log(title = "视频后台管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(videoInfoService.deleteVideoInfoByIds(ids));
    }
}
